
/**
 * @Author: 陈瑞鹏
 * @Date:   2022-10-17 15:45:23
 * @Last Modified by:   陈瑞鹏
 * @Last Modified time: 2022-10-17 15:46:06
 */
import Skill from "../models/skill/skill.model";
import utils from "../utils/utils";

export default class skill {

  /**
   * 技能初始化
   * @param roleId 角色ID
   */
  static async skillInit(roleId: number) {
    let skillData: any = await utils.get_all_json('skill/skill.json');

    for (const iterator of skillData) {
      let SkillRes: any = await Skill.findOne({ roleId, id: iterator.id });
      if (!SkillRes) {
        let info = {
          roleId,
          id: iterator.id,
          name: iterator.name
        }
        await Skill.create(info);
      }
    }
  }

}